package com.cn.wanxi.dao.impl;

import com.cn.wanxi.dao.CuisineDao;
import com.cn.wanxi.model.CuisineModel;
import com.cn.wanxi.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class CuisineImpl implements CuisineDao {
    @Override
    public List<CuisineModel> findAll() {
        String sql = "select * from tab_cuisine ";//where status=1是否启用
        List<CuisineModel> list = new ArrayList<>();
        ResultSet resultSet = JDBC.getResultSet(sql);
        try {
            while (resultSet.next()) {
                CuisineModel cuisineModel = new CuisineModel();
                cuisineModel.setTitle(resultSet.getString("name"));
                cuisineModel.setId(resultSet.getInt("id"));
                cuisineModel.setStatus(resultSet.getInt("status"));
                list.add(cuisineModel);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;
    }
}
